<!doctype html>

<title>15 Simple Integration - React From Zero</title>

<script src="https://unpkg.com/react@15.4.2/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15.4.2/dist/react-dom.js"></script>
<script src="https://unpkg.com/babel-core@5.8.38/browser.min.js"></script>

<script src="https://unpkg.com/moment@2.18.1/min/moment.min.js">
// Most of the time we have to use third party libraries
// in our applications. Here we integrate a simple one
// for date handling and use it with React. It doesn't
// use the DOM so it can be integrated fairly easy.
</script>

<div id="app"></div>

<script type="text/babel">
// Simple libraries that are called synchronous can used
// directly in JSX with the help of {}, since they are
// just function calls
var DateToday = function() {
  return <span>{moment().format('DD.MM.YYYY')}</span>
}

var tomorrow = moment().add(1, 'day')

// Nothing exiting happening here, just calling the library
// and displaying its return values. First with some
// elements, then used inside of a component.
var reactElement =
  <div>
    <h1 style={{textAlign:'center'}}>
      Tomorrow is {tomorrow.format('MMMM')} the {tomorrow.format('Do')}
    </h1>
    <DateToday/>
  </div>

ReactDOM.render(reactElement, document.getElementById('app'))
</script>